import { defineStore } from 'pinia'

export const useAppStore = defineStore({
	id: 'app',
	state: () => ({
		sidebar: {
			opened: true,
			withoutAnimation: false,
			hide: false
		},
		device: 'desktop'
	}),
	// getters: {
	//   sidebar: (state) => state.sidebar,
	//   device: (state) => state.device,
	// },
	actions: {
		toggleSideBar(withoutAnimation?: boolean) {
			if (this.sidebar.hide) {
				return false
			}
			this.sidebar.opened = !this.sidebar.opened
			this.sidebar.withoutAnimation = Boolean(withoutAnimation)
		},
		closeSideBar({ withoutAnimation }: { withoutAnimation: boolean }) {
			this.sidebar.opened = false
			this.sidebar.withoutAnimation = withoutAnimation
		},
		toggleDevice(device: string) {
			this.device = device
		}
	}
})
